package cn.training.service;

import java.util.List;

import jp.terasoluna.fw.dao.QueryDAO;
import jp.terasoluna.fw.dao.UpdateDAO;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.training.bean.UserBean;



@Service
public class HelloWorldService {
	@Autowired
	QueryDAO queryDao;

	@Autowired
	UpdateDAO updateDao;

	
//	public UserBean searchUser(UserBean frm) {
//		frm = queryDao.executeForObject("User.selectUser", frm, UserBean.class);
		//frm.setUserId("test");
		
//		return frm;
//	}
        public int insert(UserBean frm)
        {
        	int result=0;
        	try{
        		result= updateDao.execute("User.userinsert",frm);        		
           }
        	catch(Exception e){
        	   result=999;
           }
        	return result;
        }


	public int update(UserBean frm)	{
		return updateDao.execute("User.userupdate",frm);
	}
	
	public UserBean searchUser(UserBean result) 
	{
	 result=queryDao.executeForObject("User.selectUser",result,UserBean.class);
		return    result;
	}
	
	public List<UserBean> searchUserss() 
	{
		List<UserBean> result=queryDao.executeForObjectList("User.selectUsers",null);
		return    result;
	}
	public List<UserBean> searchUsers(UserBean frm) 
	{
		List<UserBean> result=queryDao.executeForObjectList("User.selectUsers", frm);
		return    result;
	}
	public int deleteUser(UserBean frm) 
	{
		int result=updateDao.execute("User.deleteUser",frm);
		return  result;
	}
	
	public int registerUser(UserBean frm) 
	{
		int result=updateDao.execute("User.userinsert",frm);
		return  result;
	}
}
